import axios from 'axios'

const config = {
  // withCredentials: true, // send cookies when cross-domain requests
  timeout: 12000 // request timeout
}
// create an axios instance
const service = axios.create(config)

// request interceptor
service.interceptors.request.use(config => {
    return config
  },
  error => {
    // console.log(error) // for debug
    return Promise.reject(error)
  }
)

// response interceptor
service.interceptors.response.use(response => {
    const res = response.data;
    return res 
  }, error => {
    return Promise.reject(error)
  }
)

export default service
